package com.example.service;

import com.example.entity.Person;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author およそ神
 * @version JDK 1.8
 */
@Component
public class MyFactory implements FallbackFactory {
    @Override
    public FeignService create(Throwable throwable) {
        return new FeignService() {
            @Override
            public boolean addPerson(Person person) {
                return false;
            }

            @Override
            public Person searchById(Integer id) {
                System.out.println("熔断处理---->没有找到数据");
                return new Person().setId(id)
                        .setAge(666)
                        .setName("fan")
                        .setId(9527);
            }

            @Override
            public List<Person> searchAll() {
                System.out.println("熔断处理---->没有找到数据");
                return null;
            }
        };
    }
}
